package course8.com.youkeda.service.impl;

import course8.com.youkeda.model.Course;
import course8.com.youkeda.service.CourseService;

import java.util.ArrayList;
import java.util.List;

public class CourseServiceImpl implements CourseService {
    private  static List<Course> COURSES=new ArrayList<>();
     static {
         COURSES.add(new Course("s_100","高等数学",48));
         COURSES.add(new Course("s_200","C语言",50));
         COURSES.add(new Course("s_300","编译原理",20));
         COURSES.add(new Course("s_400","JAVA语言",56));
     }

    public void add(Course course) {
        COURSES.add(course);
    }


    public Course get(String courseId) {
        for (Course course:COURSES
             ) {
            if (course.getId().equals(courseId)){
                return course;
            }
        }
        return null;
    }
}
